package apis

import (
	"fmt"
	"github.com/astaxie/beego"
	"models"
)

type UserAPI struct {
	beego.Controller
}

//@Title users
//@Description user list
//@Param id		path	int		true	"用户ID"
//@Success 200 {object} models.User
//@router /:id [get]
func (api *UserAPI) Users(id int) {
	fmt.Println("id :", id)

	// read one
	user := models.User{}

	models.Orm.Raw("select * from user where id = ?", id).QueryRow(&user)

	fmt.Println(user)

	api.Data["json"] = &user
	api.ServeJSON()
}
